package jp.sourceforge.akjrcp.text_douga.rcp;

import jp.sourceforge.akjrcp.text_douga.DougaSystem;
import jp.sourceforge.akjrcp.text_douga.Messages;

import com.akjava.lib.commons.video.VideoUtils;

public class TextDougaUtils {

	public static double getDefaultFPS(){
		String fpsv=Activator.getDefault().getPreferenceStore().getString(TextDougaPage.VIDEO_FPS);
		double fps=30;
		if(!fpsv.equals("")){
			if(fpsv.equals(TextDougaPage.VIDEO_FPS_OTHER)){
				fpsv=Activator.getDefault().getPreferenceStore().getString(TextDougaPage.VIDEO_FPS_OTHER);
				}
			try{
			fps=Double.parseDouble(fpsv);
			}catch(Exception e){
				DougaSystem.dougaLogger.warn(Messages.getString("textdouga_wrong_fps"));
				fps=30;
			}
		}
		return fps;
	}
	
	public static int[] getDefaultSize(){

		String size=Activator.getDefault().getPreferenceStore().getString(TextDougaPage.VIDEO_SIZE);
		if(size.equals(TextDougaPage.VIDEO_SIZE_OTHER)){
			size=Activator.getDefault().getPreferenceStore().getString(TextDougaPage.VIDEO_SIZE_OTHER);
		}
		
		int w_h[]=null;
		try{
		w_h=VideoUtils.sizeToWidthHeight(size);
		}catch(Exception e){}
		if(w_h==null){
			DougaSystem.dougaLogger.warn(Messages.getString("textdouga_wrong_size"));
			w_h=new int[]{320,240};
		}
		return w_h;
	}
}
